﻿<UserControl x:Name="_this" x:Class="z.v.OrderFix"
				 xmlns:v_sub="clr-namespace:z.v.sub"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800" Loaded="_this_Loaded">
    <Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="*"/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
		<DataGrid x:Name="tbl" LostFocus="tbl_LostFocus"
					 AutoGenerateColumns="False" Grid.Row="1" Grid.ColumnSpan="2" 
					 EnableColumnVirtualization="True"
					 ScrollViewer.CanContentScroll="True"
					 SelectionMode="Single"
					 CanUserResizeRows="False">
			<DataGrid.ContextMenu>
				<ContextMenu Placement="Mouse" Padding="0" VerticalAlignment="Top" VerticalContentAlignment="Top">
					<MenuItem x:Name="miNew" Header="Mới" Click="miNew_Click"/>
					<MenuItem x:Name="miDetails" Header="Chi tiết" Click="miDetails_Click"/>
					<Separator/>
					<!--<MenuItem x:Name="mi" Header=""/>-->
					<MenuItem x:Name="miXong" Header="Xong" Click="miXong_Click"/>
					<MenuItem x:Name="miGiao" Header="Giao" Click="miGiao_Click"/>
					<MenuItem x:Name="miThu" Header="Thu" Click="miThu_Click"/>
					<Separator/>
					<MenuItem x:Name="miPreview" Header="Xem trước" Click="miPreview_Click"/>
					<MenuItem x:Name="miPrint" Header="In" Click="miPrint_Click"/>
				</ContextMenu>
			</DataGrid.ContextMenu>
			<DataGrid.Columns>
				<DataGridTextColumn Binding="{Binding ID}" Header="ID" IsReadOnly="True" Width="Auto"/>
				<DataGridTextColumn Binding="{Binding Note}" Header="Ghi chú" Width="Auto"/>
				<DataGridTemplateColumn Header="Khách" Width="Auto">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<v_sub:AutoComplete ClassName="Customer" Tag="{Binding Customer, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Customer}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn Header="Máy" Width="Auto">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<v_sub:AutoComplete ClassName="Product" Tag="{Binding Product, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Product}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTextColumn Binding="{Binding FixInfor}" Header="Chi Tiết" IsReadOnly="True" Width="*"/>
				<DataGridTemplateColumn Header="L" Width="Auto">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<v_sub:AutoComplete ClassName="Employee" Tag="{Binding Employee_L, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Employee_L}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTextColumn Binding="{Binding Sum}" Header="Thành tiền" IsReadOnly="True" Width="Auto"/>
				<DataGridTemplateColumn Header="N" Width="Auto">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<v_sub:AutoComplete ClassName="Employee" Tag="{Binding Employee_N, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Employee_N}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn Header="Nhận" Width="102">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<DatePicker SelectedDate="{Binding Date_N,UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Date_N,StringFormat='dd-MM-yy hh:mm'}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn Header="Hẹn" Width="102">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<DatePicker SelectedDate="{Binding Date_H,UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Date_H,StringFormat='dd-MM-yy hh:mm'}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn Header="Xong" Width="102">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<DatePicker SelectedDate="{Binding Date_X,UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Date_X,StringFormat='dd-MM-yy hh:mm'}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn Header="G" Width="Auto">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<v_sub:AutoComplete ClassName="Employee" Tag="{Binding Employee_G, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Employee_G}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn Header="Giao" Width="102">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<DatePicker SelectedDate="{Binding Date_G,UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Date_G,StringFormat='dd-MM-yy hh:mm'}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn Header="T" Width="Auto">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<v_sub:AutoComplete ClassName="Employee" Tag="{Binding Employee_T, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Employee_T}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn Header="Thu" Width="102">
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							<DatePicker SelectedDate="{Binding Date_T,UpdateSourceTrigger=PropertyChanged}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Date_T,StringFormat='dd-MM-yy hh:mm'}"/>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
			</DataGrid.Columns>
		</DataGrid>
		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition Height="22"/>
				<RowDefinition Height="Auto"/>
			</Grid.RowDefinitions>
			<GroupBox>
				<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled">
					<StackPanel x:Name="spStatus" Orientation="Horizontal">
						<RadioButton Content="All" Tag="0" Checked="Status_Checked"/>
						<RadioButton Content="Chua Xong" Tag="2" Checked="Status_Checked"/>
						<RadioButton Content="Chua Giao" Tag="3" Checked="Status_Checked"/>
						<RadioButton Content="Chua Thu" Tag="4" Checked="Status_Checked"/>
					</StackPanel>
				</ScrollViewer>
			</GroupBox>
			<StackPanel Grid.Row="1" Orientation="Horizontal">
				<Label Content="Khách"/>
				<v_sub:AutoComplete x:Name="autCustomer" ClassName="Customer" Single="True" Width="200" Margin="5,0"/>
				<Button x:Name="btnSearch" Content="Tìm" Margin="5,0" Click="btnSearch_Click"/>
				<Button x:Name="btnClear" Content="Xóa" Margin="5,0" Click="btnClear_Click"/>
			</StackPanel>
		</Grid>
		<GroupBox Grid.Column="1">
			<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled">
				<StackPanel x:Name="spPages" Orientation="Horizontal"/>
			</ScrollViewer>
		</GroupBox>
	</Grid>
</UserControl>
